<div class="party">
  <nz-spin [nzTip]="'正在查询请等待...'" [nzSize]="'large'" [nzSpinning]="nzSpinning">
  <nz-collapseset>
    <nz-collapse [nzTitle]="panels.name" [nzActive]="panels.active" [nzDisabled]="panels.disabled">
      <form nz-form [nzLayout]="'inline'">
        <div nz-form-item nz-col [nzSpan]="6">
          <div nz-form-label nz-col [nzSm]="9" [nzXs]="6">
            <label>机构名称</label>
          </div>
          <div nz-form-control>
            <nz-input [(ngModel)]="partyBean.partyName" name="partyName">
            </nz-input>
          </div>
        </div>
        <div nz-form-item nz-col [nzSpan]="6">
          <div nz-form-label nz-col [nzSm]="9" [nzXs]="6">
            <label>机构类别</label>
          </div>
          <div nz-form-control>
            <nz-select style="width: 150px;" nzAllowClear [nzPlaceHolder]="'请选择'" [(ngModel)]="this.findType"
              [nzShowSearch]="true" name="partyType">
              <nz-option *ngFor="let option of searchOptions" [nzLabel]="option.label" [nzValue]="option.value">
              </nz-option>
            </nz-select>
          </div>
        </div>
        <button nz-button [nzSize]="'large'" [nzType]="'primary'" (click)="query()">查询</button>
      </form>
    </nz-collapse>
  </nz-collapseset>
  <ul nz-menu [nzMode]="'horizontal'">
    <li *ngIf="partyType=='4'" permission="SID00007" nz-menu-item (click)="add(title, content, footer)">
      <i class="anticon anticon-plus"></i>添加</li>
    <li permission="SID00008" nz-menu-item (click)="update(title, content, footer)">
      <i class="anticon anticon-copy"></i>详情\修改</li>
    <li *ngIf="partyType=='4'" permission="SID00009" nz-menu-item (click)="delete()">
      <i class="anticon anticon-delete"></i>删除</li>
    <li *ngIf="partyType=='4'" permission="SID00007" nz-menu-item (click)="showUpload(titleUpload, contentUpload, footerUpload)">
      <i class="anticon anticon-copy"></i>导入</li>
    <li *ngIf="partyType=='4'" permission="SID00007" nz-menu-item (click)="download('/information/party.xlsx','机构导入模板.xlsx')">
      <i class="anticon anticon-copy"></i>下载机构导入模板</li>

    <li *ngIf="partyType=='4'" nz-menu-item (click)="showBatch(titleBatch, contentBatch, footerBatch)">
      <i class="anticon anticon-copy"></i>发通知</li>
  </ul>
  <nz-table #nzTable [nzDataSource]="list" nzSize="middle" [nzBordered]="true" [nzIsPagination]="false" (nzDataChange)="displayDataChange($event)">
    <thead nz-thead>
      <tr>
        <th nz-th [nzCheckbox]="true">
          <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate" (ngModelChange)="checkAll($event,1)">
          </label>
        </th>
        <th nz-th>
          <span>机构名称</span>
        </th>
        <th nz-th>
          <span>机构地址</span>
        </th>
        <th nz-th>
          <span>电梯数量</span>
        </th>
        <th nz-th>
          <span>合同数量</span>
        </th>
        <th nz-th>
          <span>项目数量</span>
        </th>
        <th nz-th>
          <span>从业人数/作业人员数</span>
        </th>
        <th nz-th>
          <span>社保参保</span>
        </th>
        <th nz-th>
          <span>机构类型</span>
        </th>
        <!--<th nz-th>-->
          <!--<span>(使用/维保单位)</span>-->
        <!--</th>-->
      </tr>
    </thead>
    <tbody nz-tbody>
      <tr nz-tbody-tr *ngFor="let data of list">
        <td nz-td [nzCheckbox]="true">
          <label nz-checkbox [nzDisabled]="data.disabled" [(ngModel)]="data.checked" (ngModelChange)="refreshStatus($event)">
          </label>
        </td>
        <td nz-td>{{data.partyName}}</td>
        <td nz-td>{{data.partyAddr}}</td>
        <td nz-td>{{data.eleCount}}</td>

        <td nz-td>{{data.contractNumber}}</td>
        <td nz-td>{{data.projectNum}}</td>
        <td nz-td>{{data.userJobNum}}/{{data.userCount}}</td>
        <td nz-td>{{data.socialNum}}</td>
        <td nz-td>{{data.partyType | partyType}}</td>

      </tr>
    </tbody>
  </nz-table>

  <nz-pagination [nzPageIndex]="partyBean.currentPage" nzShowTotal [nzTotal]="total" nzShowSizeChanger
    (nzPageSizeChange)="nzPageSizeChange($event,1)" (nzPageIndexChange)="nzPageIndexChange($event,1)"
    (nzPageIndexClickChange)="nzPageIndexClickChange($event,1)" [nzPageSize]="partyBean.pageSize"></nz-pagination>

  <!--添加页面 -->
  <ng-template #title>
    <span>{{modelTitle}}</span>
  </ng-template>
  <ng-template #content>
    <party-add-page *ngIf="modal==0" [inValue]="totalList" (outPut)="addOutPut($event)"></party-add-page>
    <party-modify-page *ngIf="modal==1" [inValue]="updateData" (outPut)="addOutPut($event)"></party-modify-page>
    <maintenance-party-detail *ngIf="modal==2" [inValue]="inPartyId"></maintenance-party-detail>
    <used-party-detail *ngIf="modal==3" [inValue]="inPartyId"></used-party-detail>
  </ng-template>
  <ng-template #footer>
    <div>
    </div>
  </ng-template>

  <ng-template #titleUpload>
    <span>导入</span>
  </ng-template>
  <ng-template #contentUpload>
    <div>
      导入机构信息：
      <nz-upload nzAction="{{config.IP+config.API.uploadParty}}" [nzData]="upLoadParam" (nzChange)="uploadChage($event)"
        [nzShowUploadList]="false">
        <button nz-button>
          <i class="anticon anticon-upload"></i>
          <span>导入</span>
        </button>
      </nz-upload>
    </div>
  </ng-template>
  <ng-template #footerUpload>
    <div>
    </div>
  </ng-template>

  <nz-modal [ngClass]="sendMessage">
    <ng-template #titleBatch>
      <span>自定义发通知</span>
    </ng-template>
    <ng-template #contentBatch>
      <form nz-form>
        <div nz-form-item nz-row>
          <div nz-form-label nz-col [nzSm]="3" [nzXs]="3">
            <label for="type">选择机构类别</label>
          </div>

          <div nz-form-control nz-col  [nzXs]="5">
            <nz-select name="type" nzAllowClear [nzPlaceHolder]="'请选择发送的机构类别'" (ngModelChange)="unitTypeChangeAfter($event)"
                       [(ngModel)]="unitTypes" [nzShowSearch]="true" nzMode = "multiple">
              <nz-option *ngFor="let option of searchOptions" [nzLabel]="option.label" [nzValue]="option.value"
                         [nzDisabled]="option.disabled">
              </nz-option>
            </nz-select>
          </div>

        </div>

        <div nz-form-item nz-row>

          <div nz-form-label nz-col [nzSm]="3" [nzXs]="3">
            <label for="party">选择发送单位</label>
          </div>
          <div nz-form-control nz-col [nzSm]="9" [nzXs]="9">
            <nz-input name="units" [nzPlaceHolder]="'请选择单位'" [(ngModel)]="selectedUnitNames" [nzType]="'textarea'" [nzRows]="'5'" (click)="selectUnit(titleNotice, contentNotice, footerNotice)" ></nz-input>
          </div>
          <button nz-button nz-col [nzOffset]="2" (click)="clearSelectedUnit()"  [nzType]="'primary'"><span>重选</span></button>
        </div>

        <div nz-form-item nz-row>
          <div nz-form-label nz-col [nzSm]="3" [nzXs]="3">
            <label>用户类型</label>
          </div>
          <div nz-form-control nz-col  [nzSm]="9" [nzXs]="9">
            <nz-select name="userLevel" nzAllowClear [nzPlaceHolder]="'请选择用户类型'" [(ngModel)]="userTypes" [nzShowSearch]="true" [nzMultiple]="true">
              <nz-option *ngFor="let item of userTypesList" [nzLabel]="item.name" [nzValue]="item.value"></nz-option>
            </nz-select>
          </div>
        </div>

        <div nz-form-item nz-row>
          <div nz-form-label nz-col [nzSm]="3" [nzXs]="3">
            <label for="sendtitle">标题</label>
          </div>
          <div nz-form-control nz-col [nzSm]="9" [nzXs]="9">
            <nz-input [(ngModel)]="sendtitle" name="sendtitle" [nzPlaceHolder]="'请输入内容'"></nz-input>
          </div>
        </div>

        <div nz-form-item nz-row>
          <div nz-form-label nz-col [nzSm]="3" [nzXs]="3">
            <label for="sendContent">内容</label>
          </div>
          <div nz-form-control nz-col [nzSm]="9" [nzXs]="9">
            <nz-input [(ngModel)]="sendContent" name="sendContent" [nzType]="'textarea'" [nzRows]="'5'" [nzPlaceHolder]="'请输入内容'"></nz-input>
          </div>
        </div>

        <div nz-form-item nz-row style="margin-bottom:8px;">
          <div nz-form-control nz-col [nzSpan]="14" [nzOffset]="10">
            <button nz-button (click)="sendMessage()" [nzType]="'primary'">发送</button>
          </div>
        </div>
      </form>

    </ng-template>
    <ng-template #footerBatch>
      <div>
      </div>
    </ng-template>
  </nz-modal>

  <!--自定义发送消息通知 start -->
  <nz-modal [ngClass]="selectUnit">
    <ng-template #titleNotice>
      <span>{{modelTitle}}</span>
    </ng-template>
    <ng-template #contentNotice>
      <nz-collapseset>
        <nz-collapse [nzTitle]="panels.name" [nzActive]="panels.active" [nzDisabled]="panels.disabled">
          <form nz-form>
            <div nz-form-item nz-row>
              <div nz-form-label nz-col [nzXs]="2">
                <label>机构名称</label>
              </div>
              <div nz-form-control nz-col [nzXs]= "4">
                <nz-input [nzPlaceHolder]="'请输入'" [(ngModel)]="partyBean.noticePartyName" name="partyName" [disabled]="false"></nz-input>
              </div>

              <div nz-form-label nz-col [nzXs]="2">
                <label>单位类型</label>
              </div>
              <div nz-form-control nz-col [nzSpan]="4">
                <nz-select nzAllowClear [nzPlaceHolder]="'请选择'" [nzShowSearch]="true"  [nzSize]="'small'"
                            [(ngModel)]="noticePartyType" name="partyType" [disabled]="false">
                  <nz-option *ngFor="let item of unitTypesList" [nzLabel]="item.name" [nzValue]="item.value"></nz-option>
                </nz-select>
              </div>
              <button style="margin-left: 50px"  nz-button  [nzType]="'primary'" (click)="queryParty()">查询</button>
              <button style="margin-left: 20px"  nz-button   [nzType]="'primary'" (click)="saveSelectedParty()">保存</button>
            </div>
          </form>
        </nz-collapse>
      </nz-collapseset>
      <nz-table #nzTable [nzDataSource]="list" nzSize="middle" [nzBordered]="true" [nzIsPagination]="false" (nzDataChange)="displayDataChange($event)">
        <thead nz-thead>
        <tr>
          <th nz-th [nzCheckbox]="true">
            <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate" (ngModelChange)="checkAll($event,2)">
            </label>
          </th>
          <th nz-th>
            <span>机构名称</span>
          </th>
          <th nz-th>
            <span>机构类型</span>
          </th>
          <th nz-th>
            <span>机构地址</span>
          </th>
        </tr>
        </thead>
        <tbody nz-tbody>
        <tr nz-tbody-tr *ngFor="let data of partyList">
          <td nz-td [nzCheckbox]="true">
            <label nz-checkbox [nzDisabled]="data.disabled" [(ngModel)]="data.checked" (ngModelChange)="refreshStatus($event)">
            </label>
          </td>
          <td nz-td>{{data.partyName}}</td>
          <td nz-td>{{data.partyType | partyType}}</td>
          <td nz-td>{{data.partyAddr}}</td>
        </tr>
        </tbody>
      </nz-table>
      <nz-pagination [nzPageIndex]="partyBean.noticeCurrentPage" nzShowTotal [nzTotal]="partyTotal" nzShowSizeChanger
                     (nzPageSizeChange)="nzPageSizeChange($event,2)" (nzPageIndexChange)="nzPageIndexChange($event,2)"
                     (nzPageIndexClickChange)="nzPageIndexClickChange($event,2)" [nzPageSize]="partyBean.noticePageSize"></nz-pagination>
    </ng-template>
    <ng-template #footerNotice>
      <div>
      </div>
    </ng-template>
  </nz-modal>
  <!--自定义发送消息通知 end -->
  </nz-spin>
</div>
